package com.beimin.evedata.hsqldb;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URL;

public class AbstractSQLFile {

	protected final URL sqlURL;
	protected String sql;
	protected int statementCount = 0;

	public AbstractSQLFile(URL sqlURL) {
		this.sqlURL = sqlURL;
	}

	protected StringIterator createIterator(InputStream inputStream) throws UnsupportedEncodingException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
		return new StringIterator(reader, ';', '-');
	}

	public String getContext() {
		return "SQL statement #" + statementCount + ": " + sql + ";";
	}
}